using System;

namespace BlobSim
{
    abstract class RotationSpeedDampener
    {
        public const float DefaultStopSpeed = 0.001f;
        private float _stopSpeed;

        public RotationSpeedDampener()
        {
            setDefaultValues();
        }

        private void setDefaultValues()
        {
            _stopSpeed = DefaultStopSpeed;
        }

        public float StopSpeed
        {
            get { return _stopSpeed; }
            set
            {
                if (value < 0)
                    throw new ArgumentOutOfRangeException("value", "value must be greater than or equal to zero");

                _stopSpeed = value;
            }
        }

        public abstract float GetNewSpeed(float speed, TimeSpan delta);

        protected bool ShouldStop(float speed)
        {
            if (speed < 0)
                throw new ArgumentOutOfRangeException("speed", "value must be a positive number");

            return (speed <= StopSpeed);
        }
    }
}